#include <stdio.h>
#include <string.h>
#include <math.h>

main()
{
	// freopen("input", "r", stdin);
	// freopen("output", "w",stdout);
	int zhi[]={9,3,7};
	int shu[10];
	int n, i, j, site ,cheng;
	char ss[10];
	int icase=0, ncase, tot;

	scanf("%d", &ncase);
	while (ncase-->0)
	{
		scanf("%s", ss);
		n=strlen(ss);
		for (i=0;i<n;i++)
			shu[i+1]=ss[i]-'0';
		site=strstr(ss,"?")-ss+1;
		j=0;
		tot=0;
		for (i=n;i>=1;i--)
		{
			if (i!=site)
			{
				tot+=shu[i]*zhi[j++];
				if (j==3) j=0;
			}
			else
			{
				cheng=zhi[j++];
				if (j==3) j=0;
			}
		}
		tot=10-tot%10;
		if (tot==10) shu[site]=0;
		else
		{
			for (i=1;i<=9;i++)
				if (cheng*i%10==tot)
				{
					shu[site]=i;
					break;
				}
		}
		printf("Scenario #%d:\n", ++icase);
		for (i=1;i<=n;i++)
			printf("%d", shu[i]);
		printf("\n\n");

	}
	return 0;
}